import 'package:backend.core/core/domain/entities/web/web_subscription_duration.dart';
import 'package:equatable/equatable.dart';

const kApiWebSubscriptionMonthDurationValue = 'month';
const kApiWebSubscriptionYearDurationValue = 'year';

class ApiWebSubscriptionDurationDto extends Equatable {
  const ApiWebSubscriptionDurationDto._internal({
    required this.durationString,
  });

  final String durationString;

  @override
  List<Object?> get props {
    return [
      durationString,
    ];
  }

  factory ApiWebSubscriptionDurationDto.fromEntity(WebSubscriptionDuration subscriptionDuration) {
    late final String durationString;

    if (subscriptionDuration == WebSubscriptionDuration.month) {
      durationString = kApiWebSubscriptionMonthDurationValue;
    } else if (subscriptionDuration == WebSubscriptionDuration.year) {
      durationString = kApiWebSubscriptionYearDurationValue;
    }

    return ApiWebSubscriptionDurationDto._internal(
      durationString: durationString,
    );
  }

  @override
  String toString() {
    return durationString;
  }
}
